import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ReportVO, ReportForm, ReportQuery } from '@/api/business/report/types';

/**
 * 查询反馈记录列表
 * @param query
 * @returns {*}
 */

export const listReport = (query?: ReportQuery): AxiosPromise<ReportVO[]> => {
  return request({
    url: '/business/report/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询反馈记录详细
 * @param reportId
 */
export const getReport = (reportId: string | number): AxiosPromise<ReportVO> => {
  return request({
    url: '/business/report/' + reportId,
    method: 'get'
  });
};

/**
 * 新增反馈记录
 * @param data
 */
export const addReport = (data: ReportForm) => {
  return request({
    url: '/business/report',
    method: 'post',
    data: data
  });
};

/**
 * 修改反馈记录
 * @param data
 */
export const updateReport = (data: ReportForm) => {
  return request({
    url: '/business/report',
    method: 'put',
    data: data
  });
};

/**
 * 删除反馈记录
 * @param reportId
 */
export const delReport = (reportId: string | number | Array<string | number>) => {
  return request({
    url: '/business/report/' + reportId,
    method: 'delete'
  });
};

/**
 * 反馈通过
 * @param reportId
 */
export const approve = (reportId: string | number): AxiosPromise<ReportVO> => {
  return request({
    url: '/business/report/approve/' + reportId,
    method: 'get'
  });
};


/**
 * 反馈不通过
 * @param reportId
 */
export const reject = (reportId: string | number): AxiosPromise<ReportVO> => {
  return request({
    url: '/business/report/reject/' + reportId,
    method: 'get'
  });
};
